#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last Update:

'''common functions
'''

__revision__ = '0.1'
__author__ = 'lxd'
import os

def isExcelFile(name):
    return os.path.isfile(name) and os.path.splitext(name)[1] == '.xls'

def filesInDir(dir):
    #generate absolute paths of files in a directory
    for root, dirs, files in os.walk(dir):
        for file in files:
            yield os.path.join(root, file)

def findExcels(names):
    for name in names:
        if isExcelFile(name):
            yield name
        else:
            for file in filesInDir(name):
                if isExcelFile(file):
                    yield file

def getFileName(filePath):
    file = os.path.split(filePath)[1]
    return os.path.splitext(file)[0]


